package com.bite.common.config;

import com.bite.common.utils.RedisClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
public class RedisConfig {
    @Bean
    // 如果 spring.data.redis.host 存在 那么就创建
    @ConditionalOnProperty(prefix = "spring.data.redis", name = "host")
    public RedisClient redisUtils(StringRedisTemplate redisTemplate) {
        return new RedisClient(redisTemplate);
    }
}
